package demo.java.lang;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

public class MathDemo {

    private static Logger logger = LoggerFactory.getLogger(MathDemo.class);

    /**
     * 次方
     */
    @Test
    public void pow() {
        System.out.println("2的6次方=" + Math.pow(2, 6));
        System.out.println("2的563次方=" + Math.pow(2, 563));
        System.out.println("2的50次方=" + Math.pow(2, 50));
        for (int b = 0; b < 20; b++) {
            System.out.println("2的" + b + "次方=" + Math.pow(2, b));
        }
        System.out.println(TimeUnit.DAYS.toMinutes(1));
    }

    /**
     * 平方根
     */
    @Test
    public void sqrt() {
        logger.info("64的平方根={}", Math.sqrt(64));
    }

    /**
     * 对数
     */
    @Test
    public void log() {
        logger.info("以e为底的e的对数={}", Math.log(Math.E));
        logger.info("以10为底的100的对数={}", Math.log10(100));
        logger.info("以2为底的64的对数={}", Math.log(64) / Math.log(2));
    }

}
